//AFE5801
module rdfromadc_b(
	input				Clkin60M,
	input				rst_n,
	input				clk_in,			//100M时钟
	input		[7:0]	rd_CH,

	input		[7:0]	enFIFORst,

	input				LVRst_n,

	input		[13:0]	divinum,
	input		[7:0]	presw,
/*--------------------------------触发所需的信号--------------------------------*/
	input		[7:0]	Trigger_CH,		//触发通道选中：0选空，1选中
	input		[1:0]	TriggerMode,	//边沿触发选择：01为上升沿，10为下降沿
	input		[12:0]	TriggerLV,		//触发电平设置
	input		[13:0]	TriggerRange,	//预存储深度，0~100%，总计16k
	input		[13:0]	SamplDivinum,	//采样率衰减倍数X：X=0为50M，X≠0为50M/X
	input				VerusTrigger,	//底板发出的触发信号，接收信号后开始将数据存入FIFO

	input				TriggerST,		//底板发出的允许触发信号
	output				DTriggerSignal,	//产生的触发信号，该信号产生后关闭触发功能
	output				DTriggerRange_gt,//预存储数据存满标志




//ADC IO
	output				ADCclk,		//50M
	input				Fclk,		//50M
	input				Dclk,		//300M
	input				ADCin1,
	input				ADCin2,
	input				ADCin3,
	input				ADCin4,
	input				ADCin5,
	input				ADCin6,
	input				ADCin7,
	input				ADCin8,		//600M



	output		[11:0]	DataOut_CH1,
	output		[11:0]	DataOut_CH2,
	output		[11:0]	DataOut_CH3,
	output		[11:0]	DataOut_CH4,
	output		[11:0]	DataOut_CH5,
	output		[11:0]	DataOut_CH6,
	output		[11:0]	DataOut_CH7,
	output		[11:0]	DataOut_CH8

//Conversion result

);

wire[11:0] ADCdata1;
wire[11:0] ADCdata2;
wire[11:0] ADCdata3;
wire[11:0] ADCdata4;
wire[11:0] ADCdata5;
wire[11:0] ADCdata6;
wire[11:0] ADCdata7;
wire[11:0] ADCdata8;//50M
wire[11:0] Aclk/*synthesis keep*/;

wire ClkoutRX = Clkin60M;//100M

assign ADCclk = Clkin60M;


//串600M转并50M 外加时钟，方便纠正拼接错误
LVRX12 URX(
	.rx_in({ADCin8,ADCin7,ADCin6,ADCin5,ADCin4,ADCin3,ADCin2,ADCin1,Fclk}),
	.rx_inclock(Dclk),
	.rx_out({ADCdata18,ADCdata17,ADCdata16,ADCdata15,ADCdata14,ADCdata13,ADCdata12,ADCdata11,Aclk})
);

wire[11:0] ADCdata11;
FIFO12 UFIFO1(
	.aclr(!rst_n),
	.data(ADCdata11),
	.wrclk(Clkin60M),
	.wrreq(1'b1),
	.rdclk(Clkin60M),
	.rdreq(1'b1),
	.q(ADCdata1)
);
wire[11:0] ADCdata12;
FIFO12 UFIFO2(
	.aclr(!rst_n),
	.data(ADCdata12),
	.wrclk(Clkin60M),
	.wrreq(1'b1),
	.rdclk(Clkin60M),
	.rdreq(1'b1),
	.q(ADCdata2)
);
wire[11:0] ADCdata13;
FIFO12 UFIFO3(
	.aclr(!rst_n),
	.data(ADCdata13),
	.wrclk(Clkin60M),
	.wrreq(1'b1),
	.rdclk(Clkin60M),
	.rdreq(1'b1),
	.q(ADCdata3)
);
wire[11:0] ADCdata14;
FIFO12 UFIFO4(
	.aclr(!rst_n),
	.data(ADCdata14),
	.wrclk(Clkin60M),
	.wrreq(1'b1),
	.rdclk(Clkin60M),
	.rdreq(1'b1),
	.q(ADCdata4)
);
wire[11:0] ADCdata15;
FIFO12 UFIFO5(
	.aclr(!rst_n),
	.data(ADCdata15),
	.wrclk(Clkin60M),
	.wrreq(1'b1),
	.rdclk(Clkin60M),
	.rdreq(1'b1),
	.q(ADCdata5)
);
wire[11:0] ADCdata16;
FIFO12 UFIFO6(
	.aclr(!rst_n),
	.data(ADCdata16),
	.wrclk(Clkin60M),
	.wrreq(1'b1),
	.rdclk(Clkin60M),
	.rdreq(1'b1),
	.q(ADCdata6)
);
wire[11:0] ADCdata17;
FIFO12 UFIFO7(
	.aclr(!rst_n),
	.data(ADCdata17),
	.wrclk(Clkin60M),
	.wrreq(1'b1),
	.rdclk(Clkin60M),
	.rdreq(1'b1),
	.q(ADCdata7)
);
wire[11:0] ADCdata18;
FIFO12 UFIFO8(
	.aclr(!rst_n),
	.data(ADCdata18),
	.wrclk(Clkin60M),
	.wrreq(1'b1),
	.rdclk(Clkin60M),
	.rdreq(1'b1),
	.q(ADCdata8)
);

reg[11:0] Aclk_buff0,Aclk_buff1;
reg[11:0] ADC1_buff0,ADC1_buff1;
reg[11:0] ADC2_buff0,ADC2_buff1;
reg[11:0] ADC3_buff0,ADC3_buff1;
reg[11:0] ADC4_buff0,ADC4_buff1;
reg[11:0] ADC5_buff0,ADC5_buff1;
reg[11:0] ADC6_buff0,ADC6_buff1;
reg[11:0] ADC7_buff0,ADC7_buff1;
reg[11:0] ADC8_buff0,ADC8_buff1;
always@(posedge ClkoutRX)
begin
	if(!rst_n)
	begin
		ADC1_buff0 <= 12'h0;
		ADC1_buff1 <= 12'h0;

		ADC2_buff0 <= 12'h0;
		ADC2_buff1 <= 12'h0;

		ADC3_buff0 <= 12'h0;
		ADC3_buff1 <= 12'h0;

		ADC4_buff0 <= 12'h0;
		ADC4_buff1 <= 12'h0;

		ADC5_buff0 <= 12'h0;
		ADC5_buff1 <= 12'h0;

		ADC6_buff0 <= 12'h0;
		ADC6_buff1 <= 12'h0;

		ADC7_buff0 <= 12'h0;
		ADC7_buff1 <= 12'h0;

		ADC8_buff0 <= 12'h0;
		ADC8_buff1 <= 12'h0;

		Aclk_buff0 <= 12'h0;
		Aclk_buff1 <= 12'h0;
	end
	else
	begin
		ADC1_buff0 <= ADCdata1;
		ADC1_buff1 <= ADC1_buff0;

		ADC2_buff0 <= ADCdata2;
		ADC2_buff1 <= ADC2_buff0;

		ADC3_buff0 <= ADCdata3;
		ADC3_buff1 <= ADC3_buff0;

		ADC4_buff0 <= ADCdata4;
		ADC4_buff1 <= ADC4_buff0;

//		ADC5_buff0 <= Aclk;
//		ADC5_buff1 <= ADC5_buff0;
		ADC5_buff0 <= ADCdata5;
		ADC5_buff1 <= ADC5_buff0;

		ADC6_buff0 <= ADCdata6;
		ADC6_buff1 <= ADC6_buff0;

		ADC7_buff0 <= ADCdata7;
		ADC7_buff1 <= ADC7_buff0;

		ADC8_buff0 <= ADCdata8;
		ADC8_buff1 <= ADC8_buff0;

		Aclk_buff0 <= Aclk;
		Aclk_buff1 <= Aclk_buff0;
	end
end

reg[11:0] DataIn_CH1,DataIn_CH2,DataIn_CH3,DataIn_CH4,DataIn_CH5,DataIn_CH6,DataIn_CH7,DataIn_CH8;
always@(posedge ClkoutRX)
begin
	if(!rst_n)
	begin
		DataIn_CH1 <= 12'h0;
		DataIn_CH2 <= 12'h0;
		DataIn_CH3 <= 12'h0;
		DataIn_CH4 <= 12'h0;
		DataIn_CH5 <= 12'h0;
		DataIn_CH6 <= 12'h0;
		DataIn_CH7 <= 12'h0;
		DataIn_CH8 <= 12'h0;
	end
	else
	begin//检测上升沿位置 重新拼接并行数据
		if(!Aclk_buff1[0] && Aclk_buff1[11])
		begin
			DataIn_CH1 <= {ADC1_buff1[0],ADC1_buff1[1],ADC1_buff1[2],ADC1_buff1[3],ADC1_buff1[4],ADC1_buff1[5],ADC1_buff1[6],ADC1_buff1[7],ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11]};
			DataIn_CH2 <= {ADC2_buff1[0],ADC2_buff1[1],ADC2_buff1[2],ADC2_buff1[3],ADC2_buff1[4],ADC2_buff1[5],ADC2_buff1[6],ADC2_buff1[7],ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11]};
			DataIn_CH3 <= {ADC3_buff1[0],ADC3_buff1[1],ADC3_buff1[2],ADC3_buff1[3],ADC3_buff1[4],ADC3_buff1[5],ADC3_buff1[6],ADC3_buff1[7],ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11]};
			DataIn_CH4 <= {ADC4_buff1[0],ADC4_buff1[1],ADC4_buff1[2],ADC4_buff1[3],ADC4_buff1[4],ADC4_buff1[5],ADC4_buff1[6],ADC4_buff1[7],ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11]};
			DataIn_CH5 <= {ADC5_buff1[0],ADC5_buff1[1],ADC5_buff1[2],ADC5_buff1[3],ADC5_buff1[4],ADC5_buff1[5],ADC5_buff1[6],ADC5_buff1[7],ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11]};
			DataIn_CH6 <= {ADC6_buff1[0],ADC6_buff1[1],ADC6_buff1[2],ADC6_buff1[3],ADC6_buff1[4],ADC6_buff1[5],ADC6_buff1[6],ADC6_buff1[7],ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11]};
			DataIn_CH7 <= {ADC7_buff1[0],ADC7_buff1[1],ADC7_buff1[2],ADC7_buff1[3],ADC7_buff1[4],ADC7_buff1[5],ADC7_buff1[6],ADC7_buff1[7],ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11]};
			DataIn_CH8 <= {ADC8_buff1[0],ADC8_buff1[1],ADC8_buff1[2],ADC8_buff1[3],ADC8_buff1[4],ADC8_buff1[5],ADC8_buff1[6],ADC8_buff1[7],ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11]};
		end
		else if(!Aclk_buff1[1] && Aclk_buff1[0])
		begin
			DataIn_CH1 <= {ADC1_buff1[1],ADC1_buff1[2],ADC1_buff1[3],ADC1_buff1[4],ADC1_buff1[5],ADC1_buff1[6],ADC1_buff1[7],ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0]};
			DataIn_CH2 <= {ADC2_buff1[1],ADC2_buff1[2],ADC2_buff1[3],ADC2_buff1[4],ADC2_buff1[5],ADC2_buff1[6],ADC2_buff1[7],ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0]};
			DataIn_CH3 <= {ADC3_buff1[1],ADC3_buff1[2],ADC3_buff1[3],ADC3_buff1[4],ADC3_buff1[5],ADC3_buff1[6],ADC3_buff1[7],ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0]};
			DataIn_CH4 <= {ADC4_buff1[1],ADC4_buff1[2],ADC4_buff1[3],ADC4_buff1[4],ADC4_buff1[5],ADC4_buff1[6],ADC4_buff1[7],ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0]};
			DataIn_CH5 <= {ADC5_buff1[1],ADC5_buff1[2],ADC5_buff1[3],ADC5_buff1[4],ADC5_buff1[5],ADC5_buff1[6],ADC5_buff1[7],ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0]};
			DataIn_CH6 <= {ADC6_buff1[1],ADC6_buff1[2],ADC6_buff1[3],ADC6_buff1[4],ADC6_buff1[5],ADC6_buff1[6],ADC6_buff1[7],ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0]};
			DataIn_CH7 <= {ADC7_buff1[1],ADC7_buff1[2],ADC7_buff1[3],ADC7_buff1[4],ADC7_buff1[5],ADC7_buff1[6],ADC7_buff1[7],ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0]};
			DataIn_CH8 <= {ADC8_buff1[1],ADC8_buff1[2],ADC8_buff1[3],ADC8_buff1[4],ADC8_buff1[5],ADC8_buff1[6],ADC8_buff1[7],ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0]};
		end
		else if(!Aclk_buff1[2] && Aclk_buff1[1])
		begin
			DataIn_CH1 <= {ADC1_buff1[2],ADC1_buff1[3],ADC1_buff1[4],ADC1_buff1[5],ADC1_buff1[6],ADC1_buff1[7],ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1]};
			DataIn_CH2 <= {ADC2_buff1[2],ADC2_buff1[3],ADC2_buff1[4],ADC2_buff1[5],ADC2_buff1[6],ADC2_buff1[7],ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1]};
			DataIn_CH3 <= {ADC3_buff1[2],ADC3_buff1[3],ADC3_buff1[4],ADC3_buff1[5],ADC3_buff1[6],ADC3_buff1[7],ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1]};
			DataIn_CH4 <= {ADC4_buff1[2],ADC4_buff1[3],ADC4_buff1[4],ADC4_buff1[5],ADC4_buff1[6],ADC4_buff1[7],ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1]};
			DataIn_CH5 <= {ADC5_buff1[2],ADC5_buff1[3],ADC5_buff1[4],ADC5_buff1[5],ADC5_buff1[6],ADC5_buff1[7],ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1]};
			DataIn_CH6 <= {ADC6_buff1[2],ADC6_buff1[3],ADC6_buff1[4],ADC6_buff1[5],ADC6_buff1[6],ADC6_buff1[7],ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1]};
			DataIn_CH7 <= {ADC7_buff1[2],ADC7_buff1[3],ADC7_buff1[4],ADC7_buff1[5],ADC7_buff1[6],ADC7_buff1[7],ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1]};
			DataIn_CH8 <= {ADC8_buff1[2],ADC8_buff1[3],ADC8_buff1[4],ADC8_buff1[5],ADC8_buff1[6],ADC8_buff1[7],ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1]};
		end
		else if(!Aclk_buff1[3] && Aclk_buff1[2])
		begin
			DataIn_CH1 <= {ADC1_buff1[3],ADC1_buff1[4],ADC1_buff1[5],ADC1_buff1[6],ADC1_buff1[7],ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2]};
			DataIn_CH2 <= {ADC2_buff1[3],ADC2_buff1[4],ADC2_buff1[5],ADC2_buff1[6],ADC2_buff1[7],ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2]};
			DataIn_CH3 <= {ADC3_buff1[3],ADC3_buff1[4],ADC3_buff1[5],ADC3_buff1[6],ADC3_buff1[7],ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2]};
			DataIn_CH4 <= {ADC4_buff1[3],ADC4_buff1[4],ADC4_buff1[5],ADC4_buff1[6],ADC4_buff1[7],ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2]};
			DataIn_CH5 <= {ADC5_buff1[3],ADC5_buff1[4],ADC5_buff1[5],ADC5_buff1[6],ADC5_buff1[7],ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2]};
			DataIn_CH6 <= {ADC6_buff1[3],ADC6_buff1[4],ADC6_buff1[5],ADC6_buff1[6],ADC6_buff1[7],ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2]};
			DataIn_CH7 <= {ADC7_buff1[3],ADC7_buff1[4],ADC7_buff1[5],ADC7_buff1[6],ADC7_buff1[7],ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2]};
			DataIn_CH8 <= {ADC8_buff1[3],ADC8_buff1[4],ADC8_buff1[5],ADC8_buff1[6],ADC8_buff1[7],ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2]};
		end
		else if(!Aclk_buff1[4] && Aclk_buff1[3])
		begin
			DataIn_CH1 <= {ADC1_buff1[4],ADC1_buff1[5],ADC1_buff1[6],ADC1_buff1[7],ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2],ADC1_buff0[3]};
			DataIn_CH2 <= {ADC2_buff1[4],ADC2_buff1[5],ADC2_buff1[6],ADC2_buff1[7],ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2],ADC2_buff0[3]};
			DataIn_CH3 <= {ADC3_buff1[4],ADC3_buff1[5],ADC3_buff1[6],ADC3_buff1[7],ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2],ADC3_buff0[3]};
			DataIn_CH4 <= {ADC4_buff1[4],ADC4_buff1[5],ADC4_buff1[6],ADC4_buff1[7],ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2],ADC4_buff0[3]};
			DataIn_CH5 <= {ADC5_buff1[4],ADC5_buff1[5],ADC5_buff1[6],ADC5_buff1[7],ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2],ADC5_buff0[3]};
			DataIn_CH6 <= {ADC6_buff1[4],ADC6_buff1[5],ADC6_buff1[6],ADC6_buff1[7],ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2],ADC6_buff0[3]};
			DataIn_CH7 <= {ADC7_buff1[4],ADC7_buff1[5],ADC7_buff1[6],ADC7_buff1[7],ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2],ADC7_buff0[3]};
			DataIn_CH8 <= {ADC8_buff1[4],ADC8_buff1[5],ADC8_buff1[6],ADC8_buff1[7],ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2],ADC8_buff0[3]};
		end
		else if(!Aclk_buff1[5] && Aclk_buff1[4])
		begin
			DataIn_CH1 <= {ADC1_buff1[5],ADC1_buff1[6],ADC1_buff1[7],ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2],ADC1_buff0[3],ADC1_buff0[4]};
			DataIn_CH2 <= {ADC2_buff1[5],ADC2_buff1[6],ADC2_buff1[7],ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2],ADC2_buff0[3],ADC2_buff0[4]};
			DataIn_CH3 <= {ADC3_buff1[5],ADC3_buff1[6],ADC3_buff1[7],ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2],ADC3_buff0[3],ADC3_buff0[4]};
			DataIn_CH4 <= {ADC4_buff1[5],ADC4_buff1[6],ADC4_buff1[7],ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2],ADC4_buff0[3],ADC4_buff0[4]};
			DataIn_CH5 <= {ADC5_buff1[5],ADC5_buff1[6],ADC5_buff1[7],ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2],ADC5_buff0[3],ADC5_buff0[4]};
			DataIn_CH6 <= {ADC6_buff1[5],ADC6_buff1[6],ADC6_buff1[7],ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2],ADC6_buff0[3],ADC6_buff0[4]};
			DataIn_CH7 <= {ADC7_buff1[5],ADC7_buff1[6],ADC7_buff1[7],ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2],ADC7_buff0[3],ADC7_buff0[4]};
			DataIn_CH8 <= {ADC8_buff1[5],ADC8_buff1[6],ADC8_buff1[7],ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2],ADC8_buff0[3],ADC8_buff0[4]};
		end
		else if(!Aclk_buff1[6] && Aclk_buff1[5])
		begin
			DataIn_CH1 <= {ADC1_buff1[6],ADC1_buff1[7],ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2],ADC1_buff0[3],ADC1_buff0[4],ADC1_buff0[5]};
			DataIn_CH2 <= {ADC2_buff1[6],ADC2_buff1[7],ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2],ADC2_buff0[3],ADC2_buff0[4],ADC2_buff0[5]};
			DataIn_CH3 <= {ADC3_buff1[6],ADC3_buff1[7],ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2],ADC3_buff0[3],ADC3_buff0[4],ADC3_buff0[5]};
			DataIn_CH4 <= {ADC4_buff1[6],ADC4_buff1[7],ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2],ADC4_buff0[3],ADC4_buff0[4],ADC4_buff0[5]};
			DataIn_CH5 <= {ADC5_buff1[6],ADC5_buff1[7],ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2],ADC5_buff0[3],ADC5_buff0[4],ADC5_buff0[5]};
			DataIn_CH6 <= {ADC6_buff1[6],ADC6_buff1[7],ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2],ADC6_buff0[3],ADC6_buff0[4],ADC6_buff0[5]};
			DataIn_CH7 <= {ADC7_buff1[6],ADC7_buff1[7],ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2],ADC7_buff0[3],ADC7_buff0[4],ADC7_buff0[5]};
			DataIn_CH8 <= {ADC8_buff1[6],ADC8_buff1[7],ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2],ADC8_buff0[3],ADC8_buff0[4],ADC8_buff0[5]};
		end
		else if(!Aclk_buff1[7] && Aclk_buff1[6])
		begin
			DataIn_CH1 <= {ADC1_buff1[7],ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2],ADC1_buff0[3],ADC1_buff0[4],ADC1_buff0[5],ADC1_buff0[6]};
			DataIn_CH2 <= {ADC2_buff1[7],ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2],ADC2_buff0[3],ADC2_buff0[4],ADC2_buff0[5],ADC2_buff0[6]};
			DataIn_CH3 <= {ADC3_buff1[7],ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2],ADC3_buff0[3],ADC3_buff0[4],ADC3_buff0[5],ADC3_buff0[6]};
			DataIn_CH4 <= {ADC4_buff1[7],ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2],ADC4_buff0[3],ADC4_buff0[4],ADC4_buff0[5],ADC4_buff0[6]};
			DataIn_CH5 <= {ADC5_buff1[7],ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2],ADC5_buff0[3],ADC5_buff0[4],ADC5_buff0[5],ADC5_buff0[6]};
			DataIn_CH6 <= {ADC6_buff1[7],ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2],ADC6_buff0[3],ADC6_buff0[4],ADC6_buff0[5],ADC6_buff0[6]};
			DataIn_CH7 <= {ADC7_buff1[7],ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2],ADC7_buff0[3],ADC7_buff0[4],ADC7_buff0[5],ADC7_buff0[6]};
			DataIn_CH8 <= {ADC8_buff1[7],ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2],ADC8_buff0[3],ADC8_buff0[4],ADC8_buff0[5],ADC8_buff0[6]};
		end
		else if(!Aclk_buff1[8] && Aclk_buff1[7])
		begin
			DataIn_CH1 <= {ADC1_buff1[8],ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2],ADC1_buff0[3],ADC1_buff0[4],ADC1_buff0[5],ADC1_buff0[6],ADC1_buff0[7]};
			DataIn_CH2 <= {ADC2_buff1[8],ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2],ADC2_buff0[3],ADC2_buff0[4],ADC2_buff0[5],ADC2_buff0[6],ADC2_buff0[7]};
			DataIn_CH3 <= {ADC3_buff1[8],ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2],ADC3_buff0[3],ADC3_buff0[4],ADC3_buff0[5],ADC3_buff0[6],ADC3_buff0[7]};
			DataIn_CH4 <= {ADC4_buff1[8],ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2],ADC4_buff0[3],ADC4_buff0[4],ADC4_buff0[5],ADC4_buff0[6],ADC4_buff0[7]};
			DataIn_CH5 <= {ADC5_buff1[8],ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2],ADC5_buff0[3],ADC5_buff0[4],ADC5_buff0[5],ADC5_buff0[6],ADC5_buff0[7]};
			DataIn_CH6 <= {ADC6_buff1[8],ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2],ADC6_buff0[3],ADC6_buff0[4],ADC6_buff0[5],ADC6_buff0[6],ADC6_buff0[7]};
			DataIn_CH7 <= {ADC7_buff1[8],ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2],ADC7_buff0[3],ADC7_buff0[4],ADC7_buff0[5],ADC7_buff0[6],ADC7_buff0[7]};
			DataIn_CH8 <= {ADC8_buff1[8],ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2],ADC8_buff0[3],ADC8_buff0[4],ADC8_buff0[5],ADC8_buff0[6],ADC8_buff0[7]};
		end
		else if(!Aclk_buff1[9] && Aclk_buff1[8])
		begin
			DataIn_CH1 <= {ADC1_buff1[9],ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2],ADC1_buff0[3],ADC1_buff0[4],ADC1_buff0[5],ADC1_buff0[6],ADC1_buff0[7],ADC1_buff0[8]};
			DataIn_CH2 <= {ADC2_buff1[9],ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2],ADC2_buff0[3],ADC2_buff0[4],ADC2_buff0[5],ADC2_buff0[6],ADC2_buff0[7],ADC2_buff0[8]};
			DataIn_CH3 <= {ADC3_buff1[9],ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2],ADC3_buff0[3],ADC3_buff0[4],ADC3_buff0[5],ADC3_buff0[6],ADC3_buff0[7],ADC3_buff0[8]};
			DataIn_CH4 <= {ADC4_buff1[9],ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2],ADC4_buff0[3],ADC4_buff0[4],ADC4_buff0[5],ADC4_buff0[6],ADC4_buff0[7],ADC4_buff0[8]};
			DataIn_CH5 <= {ADC5_buff1[9],ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2],ADC5_buff0[3],ADC5_buff0[4],ADC5_buff0[5],ADC5_buff0[6],ADC5_buff0[7],ADC5_buff0[8]};
			DataIn_CH6 <= {ADC6_buff1[9],ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2],ADC6_buff0[3],ADC6_buff0[4],ADC6_buff0[5],ADC6_buff0[6],ADC6_buff0[7],ADC6_buff0[8]};
			DataIn_CH7 <= {ADC7_buff1[9],ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2],ADC7_buff0[3],ADC7_buff0[4],ADC7_buff0[5],ADC7_buff0[6],ADC7_buff0[7],ADC7_buff0[8]};
			DataIn_CH8 <= {ADC8_buff1[9],ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2],ADC8_buff0[3],ADC8_buff0[4],ADC8_buff0[5],ADC8_buff0[6],ADC8_buff0[7],ADC8_buff0[8]};
		end
		else if(!Aclk_buff1[10] && Aclk_buff1[9])
		begin
			DataIn_CH1 <= {ADC1_buff1[10],ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2],ADC1_buff0[3],ADC1_buff0[4],ADC1_buff0[5],ADC1_buff0[6],ADC1_buff0[7],ADC1_buff0[8],ADC1_buff0[9]};
			DataIn_CH2 <= {ADC2_buff1[10],ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2],ADC2_buff0[3],ADC2_buff0[4],ADC2_buff0[5],ADC2_buff0[6],ADC2_buff0[7],ADC2_buff0[8],ADC2_buff0[9]};
			DataIn_CH3 <= {ADC3_buff1[10],ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2],ADC3_buff0[3],ADC3_buff0[4],ADC3_buff0[5],ADC3_buff0[6],ADC3_buff0[7],ADC3_buff0[8],ADC3_buff0[9]};
			DataIn_CH4 <= {ADC4_buff1[10],ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2],ADC4_buff0[3],ADC4_buff0[4],ADC4_buff0[5],ADC4_buff0[6],ADC4_buff0[7],ADC4_buff0[8],ADC4_buff0[9]};
			DataIn_CH5 <= {ADC5_buff1[10],ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2],ADC5_buff0[3],ADC5_buff0[4],ADC5_buff0[5],ADC5_buff0[6],ADC5_buff0[7],ADC5_buff0[8],ADC5_buff0[9]};
			DataIn_CH6 <= {ADC6_buff1[10],ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2],ADC6_buff0[3],ADC6_buff0[4],ADC6_buff0[5],ADC6_buff0[6],ADC6_buff0[7],ADC6_buff0[8],ADC6_buff0[9]};
			DataIn_CH7 <= {ADC7_buff1[10],ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2],ADC7_buff0[3],ADC7_buff0[4],ADC7_buff0[5],ADC7_buff0[6],ADC7_buff0[7],ADC7_buff0[8],ADC7_buff0[9]};
			DataIn_CH8 <= {ADC8_buff1[10],ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2],ADC8_buff0[3],ADC8_buff0[4],ADC8_buff0[5],ADC8_buff0[6],ADC8_buff0[7],ADC8_buff0[8],ADC8_buff0[9]};
		end
		else if(!Aclk_buff1[11] && Aclk_buff1[10])
		begin
			DataIn_CH1 <= {ADC1_buff1[11],ADC1_buff0[0],ADC1_buff0[1],ADC1_buff0[2],ADC1_buff0[3],ADC1_buff0[4],ADC1_buff0[5],ADC1_buff0[6],ADC1_buff0[7],ADC1_buff0[8],ADC1_buff0[9],ADC1_buff0[10]};
			DataIn_CH2 <= {ADC2_buff1[11],ADC2_buff0[0],ADC2_buff0[1],ADC2_buff0[2],ADC2_buff0[3],ADC2_buff0[4],ADC2_buff0[5],ADC2_buff0[6],ADC2_buff0[7],ADC2_buff0[8],ADC2_buff0[9],ADC2_buff0[10]};
			DataIn_CH3 <= {ADC3_buff1[11],ADC3_buff0[0],ADC3_buff0[1],ADC3_buff0[2],ADC3_buff0[3],ADC3_buff0[4],ADC3_buff0[5],ADC3_buff0[6],ADC3_buff0[7],ADC3_buff0[8],ADC3_buff0[9],ADC3_buff0[10]};
			DataIn_CH4 <= {ADC4_buff1[11],ADC4_buff0[0],ADC4_buff0[1],ADC4_buff0[2],ADC4_buff0[3],ADC4_buff0[4],ADC4_buff0[5],ADC4_buff0[6],ADC4_buff0[7],ADC4_buff0[8],ADC4_buff0[9],ADC4_buff0[10]};
			DataIn_CH5 <= {ADC5_buff1[11],ADC5_buff0[0],ADC5_buff0[1],ADC5_buff0[2],ADC5_buff0[3],ADC5_buff0[4],ADC5_buff0[5],ADC5_buff0[6],ADC5_buff0[7],ADC5_buff0[8],ADC5_buff0[9],ADC5_buff0[10]};
			DataIn_CH6 <= {ADC6_buff1[11],ADC6_buff0[0],ADC6_buff0[1],ADC6_buff0[2],ADC6_buff0[3],ADC6_buff0[4],ADC6_buff0[5],ADC6_buff0[6],ADC6_buff0[7],ADC6_buff0[8],ADC6_buff0[9],ADC6_buff0[10]};
			DataIn_CH7 <= {ADC7_buff1[11],ADC7_buff0[0],ADC7_buff0[1],ADC7_buff0[2],ADC7_buff0[3],ADC7_buff0[4],ADC7_buff0[5],ADC7_buff0[6],ADC7_buff0[7],ADC7_buff0[8],ADC7_buff0[9],ADC7_buff0[10]};
			DataIn_CH8 <= {ADC8_buff1[11],ADC8_buff0[0],ADC8_buff0[1],ADC8_buff0[2],ADC8_buff0[3],ADC8_buff0[4],ADC8_buff0[5],ADC8_buff0[6],ADC8_buff0[7],ADC8_buff0[8],ADC8_buff0[9],ADC8_buff0[10]};
		end
		else
		begin
			DataIn_CH1 <= DataIn_CH1;
			DataIn_CH2 <= DataIn_CH2;
			DataIn_CH3 <= DataIn_CH3;
			DataIn_CH4 <= DataIn_CH4;
			DataIn_CH5 <= DataIn_CH5;
			DataIn_CH6 <= DataIn_CH6;
			DataIn_CH7 <= DataIn_CH7;
			DataIn_CH8 <= DataIn_CH8;
		end
	end
end

/*--------------------------------采样率控制--------------------------------*/
/*--------------------------------采样率控制--------------------------------*/
/*--------------------------------采样率控制--------------------------------*/
wire clkfifo;	//FIFO的写时钟
reg clkfisp;
reg[13:0] divict;
assign clkfifo = |divinum ? clkfisp : ClkoutRX;
always@(posedge clk_in or negedge rst_n)
begin
	if(!rst_n)
	begin
		clkfisp	<= 1'b0;
		divict	<= 14'h1;
	end
	else
	begin
		if(divict == divinum)
		begin
			clkfisp	<= 1'b1;
			divict	<= 14'h1;
		end
		else
		begin
			clkfisp	<= 1'b0;
			divict	<= divict + 1'b1;
		end
	end
end


wire[7:0] TriggerSignal;
assign DTriggerSignal = |TriggerSignal;
wire[7:0] TriggerRange_gt;
assign DTriggerRange_gt = &TriggerRange_gt;
trigger U1(
	.clk50M(ClkoutRX),
	.rst_n(enFIFORst[0]),
	// .rst_n(rst_n),
	// .enFIFORst(enFIFORst[0]),
	.SamplDivinum(divinum),
	.rd_CH(rd_CH[0]),
	.wr_fifo(clkfifo),

	.Trigger_CH(Trigger_CH[0]),
	.TriggerMode(TriggerMode),
	.TriggerLV(TriggerLV),
	.TriggerRange(TriggerRange),
	.VerusTrigger(VerusTrigger),

	.TriggerST(TriggerST),			//底板发出的允许触发信号
	.TriggerSignal(TriggerSignal[0]),		//产生的触发信号，该信号产生后关闭触发功能
	.TriggerRange_gt(TriggerRange_gt[0]),		//预存储数据存满标志

	.DataIn_CH(DataIn_CH1),
	.DataOut_CH(DataOut_CH1)
);



//FIFO24 U1(
//	.aclr(!enFIFORst[0]),
//
//	.data(DataIn_CH1),
//	.wrclk(clkfifo),
//	.wrreq(1'b1),
//
//	.rdclk(rd_CH[0]),
//	.rdreq(1'b1),
//
//	.q(DataOut_CH1),
//	.rdempty(),
//	.wrfull()
//);

trigger U2(
	.clk50M(ClkoutRX),
	.rst_n(enFIFORst[1]),
	// .rst_n(rst_n),
	// .enFIFORst(enFIFORst[1]),
	.SamplDivinum(divinum),
	.rd_CH(rd_CH[1]),
	.wr_fifo(clkfifo),

	.Trigger_CH(Trigger_CH[1]),
	.TriggerMode(TriggerMode),
	.TriggerLV(TriggerLV),
	.TriggerRange(TriggerRange),
	.VerusTrigger(VerusTrigger),

	.TriggerST(TriggerST),			//底板发出的允许触发信号
	.TriggerSignal(TriggerSignal[1]),		//产生的触发信号，该信号产生后关闭触发功能
	.TriggerRange_gt(TriggerRange_gt[1]),		//预存储数据存满标志

	.DataIn_CH(DataIn_CH2),
	.DataOut_CH(DataOut_CH2)
);

// FIFO24 U2(
// 	.aclr(!enFIFORst[1]),

// 	.data(DataIn_CH2),
// 	.wrclk(clkfifo),
// 	.wrreq(1'b1),

// 	.rdclk(rd_CH[1]),
// 	.rdreq(1'b1),

// 	.q(DataOut_CH2),
// 	.rdempty(),
// 	.wrfull()
// );

trigger U3(
	.clk50M(ClkoutRX),
	.rst_n(enFIFORst[2]),
	// .rst_n(rst_n),
	// .enFIFORst(enFIFORst[2]),
	.SamplDivinum(divinum),
	.rd_CH(rd_CH[2]),
	.wr_fifo(clkfifo),

	.Trigger_CH(Trigger_CH[2]),
	.TriggerMode(TriggerMode),
	.TriggerLV(TriggerLV),
	.TriggerRange(TriggerRange),
	.VerusTrigger(VerusTrigger),

	.TriggerST(TriggerST),			//底板发出的允许触发信号
	.TriggerSignal(TriggerSignal[2]),		//产生的触发信号，该信号产生后关闭触发功能
	.TriggerRange_gt(TriggerRange_gt[2]),		//预存储数据存满标志

	.DataIn_CH(DataIn_CH3),
	.DataOut_CH(DataOut_CH3)
);

// FIFO24 U3(
// 	.aclr(!enFIFORst[2]),

// 	.data(DataIn_CH3),
// 	.wrclk(clkfifo),
// 	.wrreq(1'b1),

// 	.rdclk(rd_CH[2]),
// 	.rdreq(1'b1),

// 	.q(DataOut_CH3),
// 	.rdempty(),
// 	.wrfull()
// );

trigger U4(
	.clk50M(ClkoutRX),
	.rst_n(enFIFORst[3]),
	// .rst_n(rst_n),
	// .enFIFORst(enFIFORst[3]),
	.SamplDivinum(divinum),
	.rd_CH(rd_CH[3]),
	.wr_fifo(clkfifo),

	.Trigger_CH(Trigger_CH[3]),
	.TriggerMode(TriggerMode),
	.TriggerLV(TriggerLV),
	.TriggerRange(TriggerRange),
	.VerusTrigger(VerusTrigger),

	.TriggerST(TriggerST),			//底板发出的允许触发信号
	.TriggerSignal(TriggerSignal[3]),		//产生的触发信号，该信号产生后关闭触发功能
	.TriggerRange_gt(TriggerRange_gt[3]),		//预存储数据存满标志

	.DataIn_CH(DataIn_CH4),
	.DataOut_CH(DataOut_CH4)
);

// FIFO24 U4(
// 	.aclr(!enFIFORst[3]),

// 	.data(DataIn_CH4),
// 	.wrclk(clkfifo),
// 	.wrreq(1'b1),

// 	.rdclk(rd_CH[3]),
// 	.rdreq(1'b1),

// 	.q(DataOut_CH4),
// 	.rdempty(),
// 	.wrfull()
// );

trigger U5(
	.clk50M(ClkoutRX),
	.rst_n(enFIFORst[4]),
	// .rst_n(rst_n),
	// .enFIFORst(enFIFORst[4]),
	.SamplDivinum(divinum),
	.rd_CH(rd_CH[4]),
	.wr_fifo(clkfifo),

	.Trigger_CH(Trigger_CH[4]),
	.TriggerMode(TriggerMode),
	.TriggerLV(TriggerLV),
	.TriggerRange(TriggerRange),
	.VerusTrigger(VerusTrigger),

	.TriggerST(TriggerST),			//底板发出的允许触发信号
	.TriggerSignal(TriggerSignal[4]),		//产生的触发信号，该信号产生后关闭触发功能
	.TriggerRange_gt(TriggerRange_gt[4]),		//预存储数据存满标志

	.DataIn_CH(DataIn_CH5),
	.DataOut_CH(DataOut_CH5)
);

// FIFO24 U5(
// 	.aclr(!enFIFORst[4]),

// 	.data(DataIn_CH5),
// ///	.data(ADCdata5),
// 	.wrclk(clkfifo),
// 	.wrreq(1'b1),

// 	.rdclk(rd_CH[4]),
// 	.rdreq(1'b1),

// 	.q(DataOut_CH5),
// 	.rdempty(),
// 	.wrfull()
// );

trigger U6(
	.clk50M(ClkoutRX),
	.rst_n(enFIFORst[5]),
	// .rst_n(rst_n),
	// .enFIFORst(enFIFORst[5]),
	.SamplDivinum(divinum),
	.rd_CH(rd_CH[5]),
	.wr_fifo(clkfifo),

	.Trigger_CH(Trigger_CH[5]),
	.TriggerMode(TriggerMode),
	.TriggerLV(TriggerLV),
	.TriggerRange(TriggerRange),
	.VerusTrigger(VerusTrigger),

	.TriggerST(TriggerST),			//底板发出的允许触发信号
	.TriggerSignal(TriggerSignal[5]),		//产生的触发信号，该信号产生后关闭触发功能
	.TriggerRange_gt(TriggerRange_gt[5]),		//预存储数据存满标志

	.DataIn_CH(DataIn_CH6),
	.DataOut_CH(DataOut_CH6)
);

// FIFO24 U6(
// 	.aclr(!enFIFORst[5]),

// 	.data(DataIn_CH6),
// 	.wrclk(clkfifo),
// 	.wrreq(1'b1),

// 	.rdclk(rd_CH[5]),
// 	.rdreq(1'b1),

// 	.q(DataOut_CH6),
// 	.rdempty(),
// 	.wrfull()
// );

trigger U7(
	.clk50M(ClkoutRX),
	.rst_n(enFIFORst[6]),
	// .rst_n(rst_n),
	// .enFIFORst(enFIFORst[6]),
	.SamplDivinum(divinum),
	.rd_CH(rd_CH[6]),
	.wr_fifo(clkfifo),

	.Trigger_CH(Trigger_CH[6]),
	.TriggerMode(TriggerMode),
	.TriggerLV(TriggerLV),
	.TriggerRange(TriggerRange),
	.VerusTrigger(VerusTrigger),

	.TriggerST(TriggerST),			//底板发出的允许触发信号
	.TriggerSignal(TriggerSignal[6]),		//产生的触发信号，该信号产生后关闭触发功能
	.TriggerRange_gt(TriggerRange_gt[6]),		//预存储数据存满标志

	.DataIn_CH(DataIn_CH7),
	.DataOut_CH(DataOut_CH7)
);

// FIFO24 U7(
// 	.aclr(!enFIFORst[6]),

// 	.data(DataIn_CH7),
// 	.wrclk(clkfifo),
// 	.wrreq(1'b1),

// 	.rdclk(rd_CH[6]),
// 	.rdreq(1'b1),

// 	.q(DataOut_CH7),
// 	.rdempty(),
// 	.wrfull()
// );

trigger U8(
	.clk50M(ClkoutRX),
	.rst_n(enFIFORst[7]),
	// .rst_n(rst_n),
	// .enFIFORst(enFIFORst[7]),
	.SamplDivinum(divinum),
	.rd_CH(rd_CH[7]),
	.wr_fifo(clkfifo),

	.Trigger_CH(Trigger_CH[7]),
	.TriggerMode(TriggerMode),
	.TriggerLV(TriggerLV),
	.TriggerRange(TriggerRange),
	.VerusTrigger(VerusTrigger),

	.TriggerST(TriggerST),			//底板发出的允许触发信号
	.TriggerSignal(TriggerSignal[7]),		//产生的触发信号，该信号产生后关闭触发功能
	.TriggerRange_gt(TriggerRange_gt[7]),		//预存储数据存满标志

	.DataIn_CH(DataIn_CH8),
	.DataOut_CH(DataOut_CH8)
);

// FIFO24 U8(
// 	.aclr(!enFIFORst[7]),

// 	.data(DataIn_CH8),
// 	.wrclk(clkfifo),
// 	.wrreq(1'b1),

// 	.rdclk(rd_CH[7]),
// 	.rdreq(1'b1),

// 	.q(DataOut_CH8),
// 	.rdempty(),
// 	.wrfull()
// );


endmodule
